#include "stdafx.h"

#include "utility\EventManager.hpp"

int a = 0;

void increment(int i)
{
	a += i;
}

void decrement(int i, int j)
{
	a -= i;
	a -= j;
}

TEST(EventManagerTest, registerAndCall)
{
	EventManager<int>::getInstance().addListener("increment", std::bind(increment, std::placeholders::_1));
	EventManager<int, int>::getInstance().addListener("decrement", std::bind(decrement, std::placeholders::_1, std::placeholders::_2));
	EXPECT_EQ(a, 0);
	EventManager<int>::getInstance().call("increment", 5);
	EXPECT_EQ(a, 5);
	EventManager<int, int>::getInstance().call("decrement", 1, 2);
	EXPECT_EQ(a, 2);
}